package cn.iocoder.yudao.module.nmkj.controller.app.carousel;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.nmkj.controller.admin.carousel.vo.CarouselPageReqVO;
import cn.iocoder.yudao.module.nmkj.controller.admin.carousel.vo.CarouselRespVO;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.carousel.CarouselDO;
import cn.iocoder.yudao.module.nmkj.service.carousel.CarouselService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户APP - 首页轮播图")
@RestController
@RequestMapping("/nmkj/carousel")
@Validated
public class AppCarouselController {

    @Resource
    private CarouselService carouselService;

    @GetMapping("/list")
    @Operation(summary = "获得首页轮播图列表")
    public CommonResult<List<CarouselRespVO>> getCarouselList(@Valid CarouselPageReqVO reqVO) {
        reqVO.setStatus(1); //用户端请求的数据必须为启用状态
        List<CarouselDO> lsitResult = carouselService.getCarouselList(reqVO);
        return success(BeanUtils.toBean(lsitResult, CarouselRespVO.class));
    }

}
